home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / shuffle / cd.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  36.6 KB  |  1,187 lines

  1. VERSION 2.00
  2. Begin Form CD 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Shuffle CD Player Example"
  6.    ClientHeight    =   2070
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1485
  9.    ClientWidth     =   5895
  10.    Height          =   2475
  11.    Icon            =   CD.FRX:0000
  12.    Left            =   1035
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2070
  17.    ScaleWidth      =   5895
  18.    Top             =   1140
  19.    Width           =   6015
  20.    Begin CommandButton Command5 
  21.       Caption         =   "&More >>"
  22.       Height          =   375
  23.       Left            =   4440
  24.       TabIndex        =   50
  25.       Top             =   1560
  26.       Width           =   1335
  27.    End
  28.    Begin CommandButton Command4 
  29.       Caption         =   "&About CD"
  30.       Height          =   375
  31.       Left            =   120
  32.       TabIndex        =   48
  33.       Top             =   1080
  34.       Width           =   1455
  35.    End
  36.    Begin CommandButton Command3 
  37.       Caption         =   "E&xit"
  38.       Height          =   375
  39.       Left            =   120
  40.       TabIndex        =   3
  41.       Top             =   1560
  42.       Width           =   1455
  43.    End
  44.    Begin CommandButton Command2 
  45.       Caption         =   "&Shuffle Play"
  46.       Height          =   375
  47.       Left            =   120
  48.       TabIndex        =   2
  49.       Top             =   600
  50.       Width           =   1455
  51.    End
  52.    Begin CommandButton Command1 
  53.       Caption         =   "&Load CD"
  54.       Height          =   375
  55.       Left            =   120
  56.       TabIndex        =   1
  57.       Top             =   120
  58.       Width           =   1455
  59.    End
  60.    Begin PictureBox MMControl1 
  61.       BackColor       =   &H000000FF&
  62.       Height          =   1000
  63.       Left            =   0
  64.       ScaleHeight     =   975
  65.       ScaleWidth      =   975
  66.       TabIndex        =   0
  67.       Top             =   0
  68.       Width           =   1000
  69.    End
  70.    Begin Label Label10 
  71.       BackStyle       =   0  'Transparent
  72.       Caption         =   "Shuffle Play List:"
  73.       Height          =   255
  74.       Left            =   120
  75.       TabIndex        =   49
  76.       Top             =   2280
  77.       Width           =   1575
  78.    End
  79.    Begin Line Line5 
  80.       X1              =   1680
  81.       X2              =   5040
  82.       Y1              =   1440
  83.       Y2              =   1440
  84.    End
  85.    Begin Line Line4 
  86.       X1              =   1680
  87.       X2              =   5040
  88.       Y1              =   1080
  89.       Y2              =   1080
  90.    End
  91.    Begin Line Line3 
  92.       X1              =   1680
  93.       X2              =   5280
  94.       Y1              =   720
  95.       Y2              =   720
  96.    End
  97.    Begin Line Line2 
  98.       X1              =   1680
  99.       X2              =   5280
  100.       Y1              =   360
  101.       Y2              =   360
  102.    End
  103.    Begin Line Line1 
  104.       BorderWidth     =   2
  105.       X1              =   120
  106.       X2              =   5760
  107.       Y1              =   2160
  108.       Y2              =   2160
  109.    End
  110.    Begin Label Label9 
  111.       BackColor       =   &H00FFFFFF&
  112.       BackStyle       =   0  'Transparent
  113.       Caption         =   "Track:"
  114.       Height          =   255
  115.       Left            =   1680
  116.       TabIndex        =   47
  117.       Top             =   120
  118.       Width           =   2055
  119.    End
  120.    Begin Label Label8 
  121.       Alignment       =   2  'Center
  122.       BackColor       =   &H00FFFF00&
  123.       BorderStyle     =   1  'Fixed Single
  124.       ForeColor       =   &H00000000&
  125.       Height          =   255
  126.       Left            =   5400
  127.       TabIndex        =   46
  128.       Top             =   120
  129.       Width           =   375
  130.    End
  131.    Begin Label Label7 
  132.       BackColor       =   &H00FFFFFF&
  133.       BackStyle       =   0  'Transparent
  134.       Caption         =   "Total Track Time:"
  135.       Height          =   255
  136.       Left            =   1680
  137.       TabIndex        =   4
  138.       Top             =   1200
  139.       Width           =   1935
  140.    End
  141.    Begin Label Label6 
  142.       BackColor       =   &H00FFFFFF&
  143.       BackStyle       =   0  'Transparent
  144.       Caption         =   "Elapsed Time:"
  145.       Height          =   255
  146.       Left            =   1680
  147.       TabIndex        =   45
  148.       Top             =   840
  149.       Width           =   1935
  150.    End
  151.    Begin Label Label5 
  152.       BackColor       =   &H00FFFFFF&
  153.       BackStyle       =   0  'Transparent
  154.       Caption         =   "Total Tracks Availible:"
  155.       Height          =   255
  156.       Left            =   1680
  157.       TabIndex        =   44
  158.       Top             =   480
  159.       Width           =   2055
  160.    End
  161.    Begin Label Label4 
  162.       Alignment       =   2  'Center
  163.       BackColor       =   &H00FFFF00&
  164.       BorderStyle     =   1  'Fixed Single
  165.       ForeColor       =   &H00000000&
  166.       Height          =   255
  167.       Left            =   5160
  168.       TabIndex        =   43
  169.       Top             =   1200
  170.       Width           =   615
  171.    End
  172.    Begin Label Label3 
  173.       Alignment       =   2  'Center
  174.       BackColor       =   &H00FFFF00&
  175.       BorderStyle     =   1  'Fixed Single
  176.       ForeColor       =   &H00000000&
  177.       Height          =   255
  178.       Left            =   5160
  179.       TabIndex        =   42
  180.       Top             =   840
  181.       Width           =   615
  182.    End
  183.    Begin Label Label2 
  184.       Alignment       =   2  'Center
  185.       BackColor       =   &H00FFFF00&
  186.       BorderStyle     =   1  'Fixed Single
  187.       ForeColor       =   &H00000000&
  188.       Height          =   255
  189.       Left            =   5400
  190.       TabIndex        =   41
  191.       Top             =   480
  192.       Width           =   375
  193.    End
  194.    Begin Label Label1 
  195.       Alignment       =   2  'Center
  196.       BackColor       =   &H00FFFF00&
  197.       BorderStyle     =   1  'Fixed Single
  198.       ForeColor       =   &H00000000&
  199.       Height          =   255
  200.       Index           =   36
  201.       Left            =   5400
  202.       TabIndex        =   40
  203.       Top             =   3240
  204.       Width           =   375
  205.    End
  206.    Begin Label Label1 
  207.       Alignment       =   2  'Center
  208.       BackColor       =   &H00FFFF00&
  209.       BorderStyle     =   1  'Fixed Single
  210.       ForeColor       =   &H00000000&
  211.       Height          =   255
  212.       Index           =   35
  213.       Left            =   4920
  214.       TabIndex        =   39
  215.       Top             =   3240
  216.       Width           =   375
  217.    End
  218.    Begin Label Label1 
  219.       Alignment       =   2  'Center
  220.       BackColor       =   &H00FFFF00&
  221.       BorderStyle     =   1  'Fixed Single
  222.       ForeColor       =   &H00000000&
  223.       Height          =   255
  224.       Index           =   34
  225.       Left            =   4440
  226.       TabIndex        =   38
  227.       Top             =   3240
  228.       Width           =   375
  229.    End
  230.    Begin Label Label1 
  231.       Alignment       =   2  'Center
  232.       BackColor       =   &H00FFFF00&
  233.       BorderStyle     =   1  'Fixed Single
  234.       ForeColor       =   &H00000000&
  235.       Height          =   255
  236.       Index           =   33
  237.       Left            =   3960
  238.       TabIndex        =   37
  239.       Top             =   3240
  240.       Width           =   375
  241.    End
  242.    Begin Label Label1 
  243.       Alignment       =   2  'Center
  244.       BackColor       =   &H00FFFF00&
  245.       BorderStyle     =   1  'Fixed Single
  246.       ForeColor       =   &H00000000&
  247.       Height          =   255
  248.       Index           =   32
  249.       Left            =   3480
  250.       TabIndex        =   36
  251.       Top             =   3240
  252.       Width           =   375
  253.    End
  254.    Begin Label Label1 
  255.       Alignment       =   2  'Center
  256.       BackColor       =   &H00FFFF00&
  257.       BorderStyle     =   1  'Fixed Single
  258.       ForeColor       =   &H00000000&
  259.       Height          =   255
  260.       Index           =   31
  261.       Left            =   3000
  262.       TabIndex        =   35
  263.       Top             =   3240
  264.       Width           =   375
  265.    End
  266.    Begin Label Label1 
  267.       Alignment       =   2  'Center
  268.       BackColor       =   &H00FFFF00&
  269.       BorderStyle     =   1  'Fixed Single
  270.       ForeColor       =   &H00000000&
  271.       Height          =   255
  272.       Index           =   30
  273.       Left            =   2520
  274.       TabIndex        =   34
  275.       Top             =   3240
  276.       Width           =   375
  277.    End
  278.    Begin Label Label1 
  279.       Alignment       =   2  'Center
  280.       BackColor       =   &H00FFFF00&
  281.       BorderStyle     =   1  'Fixed Single
  282.       ForeColor       =   &H00000000&
  283.       Height          =   255
  284.       Index           =   29
  285.       Left            =   2040
  286.       TabIndex        =   33
  287.       Top             =   3240
  288.       Width           =   375
  289.    End
  290.    Begin Label Label1 
  291.       Alignment       =   2  'Center
  292.       BackColor       =   &H00FFFF00&
  293.       BorderStyle     =   1  'Fixed Single
  294.       ForeColor       =   &H00000000&
  295.       Height          =   255
  296.       Index           =   28
  297.       Left            =   1560
  298.       TabIndex        =   32
  299.       Top             =   3240
  300.       Width           =   375
  301.    End
  302.    Begin Label Label1 
  303.       Alignment       =   2  'Center
  304.       BackColor       =   &H00FFFF00&
  305.       BorderStyle     =   1  'Fixed Single
  306.       ForeColor       =   &H00000000&
  307.       Height          =   255
  308.       Index           =   27
  309.       Left            =   1080
  310.       TabIndex        =   31
  311.       Top             =   3240
  312.       Width           =   375
  313.    End
  314.    Begin Label Label1 
  315.       Alignment       =   2  'Center
  316.       BackColor       =   &H00FFFF00&
  317.       BorderStyle     =   1  'Fixed Single
  318.       ForeColor       =   &H00000000&
  319.       Height          =   255
  320.       Index           =   26
  321.       Left            =   600
  322.       TabIndex        =   30
  323.       Top             =   3240
  324.       Width           =   375
  325.    End
  326.    Begin Label Label1 
  327.       Alignment       =   2  'Center
  328.       BackColor       =   &H00FFFF00&
  329.       BorderStyle     =   1  'Fixed Single
  330.       ForeColor       =   &H00000000&
  331.       Height          =   255
  332.       Index           =   25
  333.       Left            =   120
  334.       TabIndex        =   29
  335.       Top             =   3240
  336.       Width           =   375
  337.    End
  338.    Begin Label Label1 
  339.       Alignment       =   2  'Center
  340.       BackColor       =   &H00FFFF00&
  341.       BorderStyle     =   1  'Fixed Single
  342.       ForeColor       =   &H00000000&
  343.       Height          =   255
  344.       Index           =   24
  345.       Left            =   5400
  346.       TabIndex        =   28
  347.       Top             =   2880
  348.       Width           =   375
  349.    End
  350.    Begin Label Label1 
  351.       Alignment       =   2  'Center
  352.       BackColor       =   &H00FFFF00&
  353.       BorderStyle     =   1  'Fixed Single
  354.       ForeColor       =   &H00000000&
  355.       Height          =   255
  356.       Index           =   23
  357.       Left            =   4920
  358.       TabIndex        =   27
  359.       Top             =   2880
  360.       Width           =   375
  361.    End
  362.    Begin Label Label1 
  363.       Alignment       =   2  'Center
  364.       BackColor       =   &H00FFFF00&
  365.       BorderStyle     =   1  'Fixed Single
  366.       ForeColor       =   &H00000000&
  367.       Height          =   255
  368.       Index           =   22
  369.       Left            =   4440
  370.       TabIndex        =   26
  371.       Top             =   2880
  372.       Width           =   375
  373.    End
  374.    Begin Label Label1 
  375.       Alignment       =   2  'Center
  376.       BackColor       =   &H00FFFF00&
  377.       BorderStyle     =   1  'Fixed Single
  378.       ForeColor       =   &H00000000&
  379.       Height          =   255
  380.       Index           =   21
  381.       Left            =   3960
  382.       TabIndex        =   25
  383.       Top             =   2880
  384.       Width           =   375
  385.    End
  386.    Begin Label Label1 
  387.       Alignment       =   2  'Center
  388.       BackColor       =   &H00FFFF00&
  389.       BorderStyle     =   1  'Fixed Single
  390.       ForeColor       =   &H00000000&
  391.       Height          =   255
  392.       Index           =   20
  393.       Left            =   3480
  394.       TabIndex        =   24
  395.       Top             =   2880
  396.       Width           =   375
  397.    End
  398.    Begin Label Label1 
  399.       Alignment       =   2  'Center
  400.       BackColor       =   &H00FFFF00&
  401.       BorderStyle     =   1  'Fixed Single
  402.       ForeColor       =   &H00000000&
  403.       Height          =   255
  404.       Index           =   19
  405.       Left            =   3000
  406.       TabIndex        =   23
  407.       Top             =   2880
  408.       Width           =   375
  409.    End
  410.    Begin Label Label1 
  411.       Alignment       =   2  'Center
  412.       BackColor       =   &H00FFFF00&
  413.       BorderStyle     =   1  'Fixed Single
  414.       ForeColor       =   &H00000000&
  415.       Height          =   255
  416.       Index           =   18
  417.       Left            =   2520
  418.       TabIndex        =   22
  419.       Top             =   2880
  420.       Width           =   375
  421.    End
  422.    Begin Label Label1 
  423.       Alignment       =   2  'Center
  424.       BackColor       =   &H00FFFF00&
  425.       BorderStyle     =   1  'Fixed Single
  426.       ForeColor       =   &H00000000&
  427.       Height          =   255
  428.       Index           =   17
  429.       Left            =   2040
  430.       TabIndex        =   21
  431.       Top             =   2880
  432.       Width           =   375
  433.    End
  434.    Begin Label Label1 
  435.       Alignment       =   2  'Center
  436.       BackColor       =   &H00FFFF00&
  437.       BorderStyle     =   1  'Fixed Single
  438.       ForeColor       =   &H00000000&
  439.       Height          =   255
  440.       Index           =   16
  441.       Left            =   1560
  442.       TabIndex        =   20
  443.       Top             =   2880
  444.       Width           =   375
  445.    End
  446.    Begin Label Label1 
  447.       Alignment       =   2  'Center
  448.       BackColor       =   &H00FFFF00&
  449.       BorderStyle     =   1  'Fixed Single
  450.       ForeColor       =   &H00000000&
  451.       Height          =   255
  452.       Index           =   15
  453.       Left            =   1080
  454.       TabIndex        =   19
  455.       Top             =   2880
  456.       Width           =   375
  457.    End
  458.    Begin Label Label1 
  459.       Alignment       =   2  'Center
  460.       BackColor       =   &H00FFFF00&
  461.       BorderStyle     =   1  'Fixed Single
  462.       ForeColor       =   &H00000000&
  463.       Height          =   255
  464.       Index           =   14
  465.       Left            =   600
  466.       TabIndex        =   18
  467.       Top             =   2880
  468.       Width           =   375
  469.    End
  470.    Begin Label Label1 
  471.       Alignment       =   2  'Center
  472.       BackColor       =   &H00FFFF00&
  473.       BorderStyle     =   1  'Fixed Single
  474.       ForeColor       =   &H00000000&
  475.       Height          =   255
  476.       Index           =   13
  477.       Left            =   120
  478.       TabIndex        =   17
  479.       Top             =   2880
  480.       Width           =   375
  481.    End
  482.    Begin Label Label1 
  483.       Alignment       =   2  'Center
  484.       BackColor       =   &H00FFFF00&
  485.       BorderStyle     =   1  'Fixed Single
  486.       ForeColor       =   &H00000000&
  487.       Height          =   255
  488.       Index           =   12
  489.       Left            =   5400
  490.       TabIndex        =   16
  491.       Top             =   2520
  492.       Width           =   375
  493.    End
  494.    Begin Label Label1 
  495.       Alignment       =   2  'Center
  496.       BackColor       =   &H00FFFF00&
  497.       BorderStyle     =   1  'Fixed Single
  498.       ForeColor       =   &H00000000&
  499.       Height          =   255
  500.       Index           =   11
  501.       Left            =   4920
  502.       TabIndex        =   15
  503.       Top             =   2520
  504.       Width           =   375
  505.    End
  506.    Begin Label Label1 
  507.       Alignment       =   2  'Center
  508.       BackColor       =   &H00FFFF00&
  509.       BorderStyle     =   1  'Fixed Single
  510.       ForeColor       =   &H00000000&
  511.       Height          =   255
  512.       Index           =   10
  513.       Left            =   4440
  514.       TabIndex        =   14
  515.       Top             =   2520
  516.       Width           =   375
  517.    End
  518.    Begin Label Label1 
  519.       Alignment       =   2  'Center
  520.       BackColor       =   &H00FFFF00&
  521.       BorderStyle     =   1  'Fixed Single
  522.       ForeColor       =   &H00000000&
  523.       Height          =   255
  524.       Index           =   9
  525.       Left            =   3960
  526.       TabIndex        =   13
  527.       Top             =   2520
  528.       Width           =   375
  529.    End
  530.    Begin Label Label1 
  531.       Alignment       =   2  'Center
  532.       BackColor       =   &H00FFFF00&
  533.       BorderStyle     =   1  'Fixed Single
  534.       ForeColor       =   &H00000000&
  535.       Height          =   255
  536.       Index           =   8
  537.       Left            =   3480
  538.       TabIndex        =   12
  539.       Top             =   2520
  540.       Width           =   375
  541.    End
  542.    Begin Label Label1 
  543.       Alignment       =   2  'Center
  544.       BackColor       =   &H00FFFF00&
  545.       BorderStyle     =   1  'Fixed Single
  546.       ForeColor       =   &H00000000&
  547.       Height          =   255
  548.       Index           =   7
  549.       Left            =   3000
  550.       TabIndex        =   11
  551.       Top             =   2520
  552.       Width           =   375
  553.    End
  554.    Begin Label Label1 
  555.       Alignment       =   2  'Center
  556.       BackColor       =   &H00FFFF00&
  557.       BorderStyle     =   1  'Fixed Single
  558.       ForeColor       =   &H00000000&
  559.       Height          =   255
  560.       Index           =   6
  561.       Left            =   2520
  562.       TabIndex        =   10
  563.       Top             =   2520
  564.       Width           =   375
  565.    End
  566.    Begin Label Label1 
  567.       Alignment       =   2  'Center
  568.       BackColor       =   &H00FFFF00&
  569.       BorderStyle     =   1  'Fixed Single
  570.       ForeColor       =   &H00000000&
  571.       Height          =   255
  572.       Index           =   5
  573.       Left            =   2040
  574.       TabIndex        =   9
  575.       Top             =   2520
  576.       Width           =   375
  577.    End
  578.    Begin Label Label1 
  579.       Alignment       =   2  'Center
  580.       BackColor       =   &H00FFFF00&
  581.       BorderStyle     =   1  'Fixed Single
  582.       ForeColor       =   &H00000000&
  583.       Height          =   255
  584.       Index           =   4
  585.       Left            =   1560
  586.       TabIndex        =   8
  587.       Top             =   2520
  588.       Width           =   375
  589.    End
  590.    Begin Label Label1 
  591.       Alignment       =   2  'Center
  592.       BackColor       =   &H00FFFF00&
  593.       BorderStyle     =   1  'Fixed Single
  594.       ForeColor       =   &H00000000&
  595.       Height          =   255
  596.       Index           =   3
  597.       Left            =   1080
  598.       TabIndex        =   7
  599.       Top             =   2520
  600.       Width           =   375
  601.    End
  602.    Begin Label Label1 
  603.       Alignment       =   2  'Center
  604.       BackColor       =   &H00FFFF00&
  605.       BorderStyle     =   1  'Fixed Single
  606.       ForeColor       =   &H00000000&
  607.       Height          =   255
  608.       Index           =   2
  609.       Left            =   600
  610.       TabIndex        =   6
  611.       Top             =   2520
  612.       Width           =   375
  613.    End
  614.    Begin Label Label1 
  615.       Alignment       =   2  'Center
  616.       BackColor       =   &H00FFFF00&
  617.       BorderStyle     =   1  'Fixed Single
  618.       ForeColor       =   &H00000000&
  619.       Height          =   255
  620.       Index           =   1
  621.       Left            =   120
  622.       TabIndex        =   5
  623.       Top             =   2520
  624.       Width           =   375
  625.    End
  626. '============================================
  627. ' SHUFFLE CD PLAYER EXAMPLE
  628. ' Copyright(c) 1994 Larry Robert Seater
  629. '============================================
  630. ' Disclaimer of Warranty:
  631. ' This software and the accompanying files are 'as is'
  632. ' and without warranties as to performance of the
  633. ' software and the accompanying files or any other
  634. ' warranties whether expressed or implied.
  635. ' No warranty of fitness for a particular purpose
  636. ' is offered.
  637. ' You may not sell this software or it's source code.
  638. ' You may use this code in any way you find useful.
  639. ' Enough said!
  640. ' This is an example of some things I've learned
  641. ' about the MCI.VBX custom control from the Visual
  642. ' Basic Professional Edition.  This is written in
  643. ' VB Pro 3.0 and needs to be run (I think) on the
  644. ' same.  There may be a few bugs, but I knocked it
  645. ' out in a couple of hours.  There are a few other
  646. ' tricks(?) in the code too.
  647. ' Please if you have any comments (good or bad) or
  648. ' any suggestions, or want to trade code write me or
  649. ' E-Mail me at:
  650. ' AOL: LarryS8302
  651. ' Land Mail: Larry Seater
  652. '            2124 NE 36th Av.
  653. '            Portland, OR 97212
  654. ' Thanks!
  655. Sub ClearAll ()
  656.     ' Clears all the label1(index) captions.
  657.     For i = 1 To 36
  658.         Label1(i).Caption = ""
  659.     Next i
  660. End Sub
  661. Sub Command1_Click ()
  662.     MousePointer = 11
  663.     ' Open the CD device -- the disk must already be
  664.     ' in the drive.
  665.     On Error GoTo MCI_ERROR
  666.     MMControl1.Command = "Open"
  667.     On Error GoTo 0
  668.     ' Set Shuf flag to false.
  669.     Flag = False
  670.     ' Set the time format
  671.     MMControl1.TimeFormat = MCI_FORMAT_TMSF
  672.     ' Disable the Load command button.
  673.     Command1.Enabled = False
  674.     Command2.Enabled = True
  675.     Label2.Caption = Str$(MMControl1.Tracks)
  676.     Label8.Caption = "1"
  677.     If Label2.Caption = 1 Then
  678.         msg = "One track, may not be an Audio CD!"
  679.         MsgBox msg, 64, "CD Player"
  680.     End If
  681.     MousePointer = 0
  682.     Exit Sub
  683. MCI_ERROR:
  684.     DisplayErrorMessageBox
  685.     Resume MCI_EXIT
  686. MCI_EXIT:
  687.     Unload CD
  688. End Sub
  689. Sub Command2_Click ()
  690.     Call ClearAll
  691.     Flag = False
  692.     TotalTrk = MMControl1.Tracks
  693.     Select Case Val(TotalTrk)
  694.     Case 1
  695.         msg = "One track, may not be an Audio CD!"
  696.         MsgBox msg, 64, "Shuffle CD Player Example"
  697.         Call MMControl1_StopClick(-1)
  698.     Case 2 To 36
  699.         Call RandomOrder
  700.     Case Is > 36
  701.         msg = "Only support for 36 tracks!  Unable to Shuffle!"
  702.         MsgBox msg, 64, "Shuffle CD Player Example"
  703.         Call MMControl1_StopClick(-1)
  704.     End Select
  705. End Sub
  706. Sub Command3_Click ()
  707.     MMControl1.Command = "Stop"
  708.     MMControl1.Command = "Close"
  709.     End
  710. End Sub
  711. Sub Command4_Click ()
  712.     AboutBox.Show
  713. End Sub
  714. Sub Command5_Click ()
  715.     If Command5.Caption = "&More >>" Then
  716.         CD.Height = 4025
  717.         Command5.Caption = "&Less <<"
  718.     Else
  719.         CD.Height = 2475
  720.         Command5.Caption = "&More >>"
  721.     End If
  722. End Sub
  723. Sub Form_Load ()
  724.     'See if CD is already running.
  725.     If App.PrevInstance Then
  726.         msg$ = "Shuffle CD Player Example already running!"
  727.         MsgBox msg$, 48
  728.         End
  729.     End If
  730.     ' Center Form on Screen.
  731.     Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2.28
  732.     ' Force the MCI control to complete before returning
  733.     ' to the application.
  734.     MMControl1.Wait = True
  735.     MMControl1.UpdateInterval = 0
  736.     Command2.Enabled = False
  737.     Label2.Caption = "0"
  738.     Label3.Caption = "00:00"
  739.     Label4.Caption = "00:00"
  740.     Label8.Caption = "0"
  741.     ' Set the DeviceType to a musical CD device.
  742.     MMControl1.DeviceType = "CDAudio"
  743. End Sub
  744. Sub Form_Unload (Cancel As Integer)
  745.     MMControl1.Command = "Stop"
  746.     MMControl1.Command = "Close"
  747.     End
  748. End Sub
  749. Sub MMControl1_EjectClick (Cancel As Integer)
  750.     Flag = False
  751.     Call ClearAll
  752.     Command1.Enabled = True
  753.     Command2.Enabled = False
  754.     Label2.Caption = "0"
  755.     Label3.Caption = "00:00"
  756.     Label4.Caption = "00:00"
  757.     Label8.Caption = "0"
  758.     MMControl1.UpdateInterval = 0
  759.     ' Eject the disk from the CD drive, and close the device.
  760.     On Error GoTo MCI_ERROR2
  761.     MMControl1.Command = "Eject"
  762.     MMControl1.Command = "Close"
  763.     On Error GoTo 0
  764.     Exit Sub
  765. MCI_ERROR2:
  766.     DisplayErrorMessageBox
  767.     Resume Next
  768. End Sub
  769. Sub MMControl1_NextClick (Cancel As Integer)
  770.     Call ClearAll
  771. End Sub
  772. Sub MMControl1_PauseClick (Cancel As Integer)
  773.     Flag = False
  774.     Call ClearAll
  775.     MMControl1.UpdateInterval = 0
  776. End Sub
  777. Sub MMControl1_PlayClick (Cancel As Integer)
  778.     Flag = False
  779.     Call ClearAll
  780.     MMControl1.UpdateInterval = 1000
  781. End Sub
  782. Sub MMControl1_PrevClick (Cancel As Integer)
  783.     Call ClearAll
  784. End Sub
  785. Sub MMControl1_StatusUpdate ()
  786. ' See article ID: Q94012 in new knowlege base.
  787. ' The least significant byte is stored in byte1 and the most significant byte
  788. ' is stored in byte4.
  789.     byte1 = MMControl1.Position And &HFF&
  790.     byte2 = (MMControl1.Position And &HFF00&) \ &H100
  791.     byte3 = (MMControl1.Position And &HFF0000) \ &H10000
  792.     byte4 = (MMControl1.Position And &H7F000000) \ &H1000000
  793.     ' put sign bit back into byte4
  794.     If (MMControl1.Position And &H80000000) <> 0 Then
  795.         byte4 = byte4 + &H80
  796.     End If
  797.     ' Set the track number to the current track.
  798.     Trk = byte1   'MMControl1.Position And &HFF
  799.     Label8.Caption = Trk
  800.     Label3.Caption = Format$(byte2, "00") + ":" + Format$(byte3, "00")
  801.     MMControl1.Track = Trk  'Tells the TrackLength which track to measure.
  802.     byteA = MMControl1.TrackLength And &HFF&
  803.     byteB = (MMControl1.TrackLength And &HFF00&) \ &H100
  804.     If (MMControl1.TrackLength And &H80000000) <> 0 Then
  805.         byteB = byteB + &H80
  806.     End If
  807.     Label4.Caption = Format$(byteA, "00") + ":" + Format$(byteB, "00")
  808.     ' See if Shuf should be called or not based on flag var.
  809.     If MMControl1.Mode = MCI_MODE_STOP Then
  810.         If Flag = True Then
  811.             Call ShufflePlay
  812.         Else
  813.             Call MMControl1_StopClick(-1)
  814.         End If
  815.     End If
  816. End Sub
  817. Sub MMControl1_StopClick (Cancel As Integer)
  818.     Flag = False
  819.     Call ClearAll
  820.     MMControl1.UpdateInterval = 0
  821.     ' Reset the CD to track 1.
  822.     MMControl1.To = MMControl1.Start
  823.     MMControl1.Command = "Seek"
  824.     MMControl1.Track = 1
  825.     Trk = 1
  826.     Label3.Caption = "00:00"
  827.     Label4.Caption = "00:00"
  828.     Label8.Caption = Trk
  829. End Sub
  830. Sub RandomOrder ()
  831.     Dim TotalNum
  832.     TotalNum = Val(Label2.Caption)
  833.     Dim Top As Integer
  834.     Dim i As Integer, J As Integer
  835.     Dim IdxTemp As Integer
  836.     ReDim TempArray(1 To TotalNum) As Integer
  837.     ReDim Answer(1 To TotalNum) As Integer
  838.     'Generate hidden random sequence:
  839.     Randomize
  840.     For i = 1 To TotalNum
  841.         TempArray(i) = i
  842.     Next i
  843.     Top = TotalNum
  844.     For i = 1 To Top
  845.         IdxTemp = Int(Top * Rnd + 1)
  846.         Answer(i) = TempArray(IdxTemp)
  847.         For J = IdxTemp To Top - 1
  848.             TempArray(J) = TempArray(J + 1)
  849.         Next J
  850.         Top = Top - 1
  851.     Next i
  852.     ' Display the track order in Immediate Window
  853.     ' for program testing:
  854.     For i = 1 To TotalNum
  855.         Debug.Print Answer(i); " ";
  856.     Next i
  857.     Debug.Print
  858.     For i = 1 To TotalNum
  859.         Label1(i) = Str$(Answer(i))
  860.     Next i
  861.     Call ShufflePlay
  862. End Sub
  863. Sub ShufflePlay ()
  864.     MousePointer = 11
  865.     If Flag = False Then
  866.         NewCount = 0
  867.     End If
  868.     ' Force the MCI control to complete before returning
  869.     ' to the application.
  870.     MMControl1.Wait = True
  871.     MMControl1.UpdateInterval = 0
  872.     'Set Flag to True for controlling Shuffle play.
  873.     Flag = True
  874.     ' Set the DeviceType to a musical CD device.
  875.     MMControl1.DeviceType = "CDAudio"
  876.     ' Open Device and set time format.
  877.     MMControl1.Command = "Open"
  878.     MMControl1.TimeFormat = MCI_FORMAT_TMSF
  879.     ' Set var to the total number of tracks.
  880.     TotalTrk = MMControl1.Tracks
  881.     Do
  882.         C = 1 + NewCount
  883.         Trk = Label1(1).Caption
  884.         If C = 1 Then
  885.             Exit Do
  886.         Else
  887.             Select Case C
  888.             Case 2
  889.                 Trk = Label1(2).Caption
  890.                 If Trk = "" Then
  891.                     MousePointer = 0
  892.                     Call MMControl1_StopClick(-1)
  893.                     Exit Sub
  894.                 End If
  895.                 Exit Do
  896.             Case 3
  897.                 Trk = Label1(3).Caption
  898.                 If Trk = "" Then
  899.                     MousePointer = 0
  900.                     Call MMControl1_StopClick(-1)
  901.                     Exit Sub
  902.                 End If
  903.                 Exit Do
  904.             Case 4
  905.                 Trk = Label1(4).Caption
  906.                 If Trk = "" Then
  907.                     MousePointer = 0
  908.                     Call MMControl1_StopClick(-1)
  909.                     Exit Sub
  910.                 End If
  911.                 Exit Do
  912.             Case 5
  913.                 Trk = Label1(5).Caption
  914.                 If Trk = "" Then
  915.                     MousePointer = 0
  916.                     Call MMControl1_StopClick(-1)
  917.                     Exit Sub
  918.                 End If
  919.                 Exit Do
  920.             Case 6
  921.                 Trk = Label1(6).Caption
  922.                 If Trk = "" Then
  923.                     MousePointer = 0
  924.                     Call MMControl1_StopClick(-1)
  925.                     Exit Sub
  926.                 End If
  927.                 Exit Do
  928.             Case 7
  929.                 Trk = Label1(7).Caption
  930.                 If Trk = "" Then
  931.                     MousePointer = 0
  932.                     Call MMControl1_StopClick(-1)
  933.                     Exit Sub
  934.                 End If
  935.                 Exit Do
  936.             Case 8
  937.                 Trk = Label1(8).Caption
  938.                 If Trk = "" Then
  939.                     MousePointer = 0
  940.                     Call MMControl1_StopClick(-1)
  941.                     Exit Sub
  942.                 End If
  943.                 Exit Do
  944.             Case 9
  945.                 Trk = Label1(9).Caption
  946.                 If Trk = "" Then
  947.                     MousePointer = 0
  948.                     Call MMControl1_StopClick(-1)
  949.                     Exit Sub
  950.                 End If
  951.                 Exit Do
  952.             Case 10
  953.                 Trk = Label1(10).Caption
  954.                 If Trk = "" Then
  955.                     MousePointer = 0
  956.                     Call MMControl1_StopClick(-1)
  957.                     Exit Sub
  958.                 End If
  959.                 Exit Do
  960.             Case 11
  961.                 Trk = Label1(11).Caption
  962.                 If Trk = "" Then
  963.                     MousePointer = 0
  964.                     Call MMControl1_StopClick(-1)
  965.                     Exit Sub
  966.                 End If
  967.                 Exit Do
  968.             Case 12
  969.                 Trk = Label1(12).Caption
  970.                 If Trk = "" Then
  971.                     MousePointer = 0
  972.                     Call MMControl1_StopClick(-1)
  973.                     Exit Sub
  974.                 End If
  975.                 Exit Do
  976.             Case 13
  977.                 Trk = Label1(13).Caption
  978.                 If Trk = "" Then
  979.                     MousePointer = 0
  980.                     Call MMControl1_StopClick(-1)
  981.                     Exit Sub
  982.                 End If
  983.                 Exit Do
  984.             Case 14
  985.                 Trk = Label1(14).Caption
  986.                 If Trk = "" Then
  987.                     MousePointer = 0
  988.                     Call MMControl1_StopClick(-1)
  989.                     Exit Sub
  990.                 End If
  991.                 Exit Do
  992.             Case 15
  993.                 Trk = Label1(15).Caption
  994.                 If Trk = "" Then
  995.                     MousePointer = 0
  996.                     Call MMControl1_StopClick(-1)
  997.                     Exit Sub
  998.                 End If
  999.                 Exit Do
  1000.             Case 16
  1001.                 Trk = Label1(16).Caption
  1002.                 If Trk = "" Then
  1003.                     MousePointer = 0
  1004.                     Call MMControl1_StopClick(-1)
  1005.                     Exit Sub
  1006.                 End If
  1007.                 Exit Do
  1008.             Case 17
  1009.                 Trk = Label1(17).Caption
  1010.                 If Trk = "" Then
  1011.                     MousePointer = 0
  1012.                     Call MMControl1_StopClick(-1)
  1013.                     Exit Sub
  1014.                 End If
  1015.                 Exit Do
  1016.             Case 18
  1017.                 Trk = Label1(18).Caption
  1018.                 If Trk = "" Then
  1019.                     MousePointer = 0
  1020.                     Call MMControl1_StopClick(-1)
  1021.                     Exit Sub
  1022.                 End If
  1023.                 Exit Do
  1024.             Case 19
  1025.                 Trk = Label1(19).Caption
  1026.                 If Trk = "" Then
  1027.                     MousePointer = 0
  1028.                     Call MMControl1_StopClick(-1)
  1029.                     Exit Sub
  1030.                 End If
  1031.                 Exit Do
  1032.             Case 20
  1033.                 Trk = Label1(20).Caption
  1034.                 If Trk = "" Then
  1035.                     MousePointer = 0
  1036.                     Call MMControl1_StopClick(-1)
  1037.                     Exit Sub
  1038.                 End If
  1039.                 Exit Do
  1040.             Case 21
  1041.                 Trk = Label1(21).Caption
  1042.                 If Trk = "" Then
  1043.                     MousePointer = 0
  1044.                     Call MMControl1_StopClick(-1)
  1045.                     Exit Sub
  1046.                 End If
  1047.                 Exit Do
  1048.             Case 22
  1049.                 Trk = Label1(22).Caption
  1050.                 If Trk = "" Then
  1051.                     MousePointer = 0
  1052.                     Call MMControl1_StopClick(-1)
  1053.                     Exit Sub
  1054.                 End If
  1055.                 Exit Do
  1056.             Case 23
  1057.                 Trk = Label1(23).Caption
  1058.                 If Trk = "" Then
  1059.                     MousePointer = 0
  1060.                     Call MMControl1_StopClick(-1)
  1061.                     Exit Sub
  1062.                 End If
  1063.                 Exit Do
  1064.             Case 24
  1065.                 Trk = Label1(24).Caption
  1066.                 If Trk = "" Then
  1067.                     MousePointer = 0
  1068.                     Call MMControl1_StopClick(-1)
  1069.                     Exit Sub
  1070.                 End If
  1071.                 Exit Do
  1072.             Case 25
  1073.                 Trk = Label1(25).Caption
  1074.                 If Trk = "" Then
  1075.                     MousePointer = 0
  1076.                     Call MMControl1_StopClick(-1)
  1077.                     Exit Sub
  1078.                 End If
  1079.                 Exit Do
  1080.             Case 26
  1081.                 Trk = Label1(26).Caption
  1082.                 If Trk = "" Then
  1083.                     MousePointer = 0
  1084.                     Call MMControl1_StopClick(-1)
  1085.                     Exit Sub
  1086.                 End If
  1087.                 Exit Do
  1088.             Case 27
  1089.                 Trk = Label1(27).Caption
  1090.                 If Trk = "" Then
  1091.                     MousePointer = 0
  1092.                     Call MMControl1_StopClick(-1)
  1093.                     Exit Sub
  1094.                 End If
  1095.                 Exit Do
  1096.             Case 28
  1097.                 Trk = Label1(28).Caption
  1098.                 If Trk = "" Then
  1099.                     MousePointer = 0
  1100.                     Call MMControl1_StopClick(-1)
  1101.                     Exit Sub
  1102.                 End If
  1103.                 Exit Do
  1104.             Case 29
  1105.                 Trk = Label1(29).Caption
  1106.                 If Trk = "" Then
  1107.                     MousePointer = 0
  1108.                     Call MMControl1_StopClick(-1)
  1109.                     Exit Sub
  1110.                 End If
  1111.                 Exit Do
  1112.             Case 30
  1113.                 Trk = Label1(30).Caption
  1114.                 If Trk = "" Then
  1115.                     MousePointer = 0
  1116.                     Call MMControl1_StopClick(-1)
  1117.                     Exit Sub
  1118.                 End If
  1119.                 Exit Do
  1120.             Case 31
  1121.                 Trk = Label1(31).Caption
  1122.                 If Trk = "" Then
  1123.                     MousePointer = 0
  1124.                     Call MMControl1_StopClick(-1)
  1125.                     Exit Sub
  1126.                 End If
  1127.                 Exit Do
  1128.             Case 32
  1129.                 Trk = Label1(32).Caption
  1130.                 If Trk = "" Then
  1131.                     MousePointer = 0
  1132.                     Call MMControl1_StopClick(-1)
  1133.                     Exit Sub
  1134.                 End If
  1135.                 Exit Do
  1136.             Case 33
  1137.                 Trk = Label1(33).Caption
  1138.                 If Trk = "" Then
  1139.                     MousePointer = 0
  1140.                     Call MMControl1_StopClick(-1)
  1141.                     Exit Sub
  1142.                 End If
  1143.                 Exit Do
  1144.             Case 34
  1145.                 Trk = Label1(34).Caption
  1146.                 If Trk = "" Then
  1147.                     MousePointer = 0
  1148.                     Call MMControl1_StopClick(-1)
  1149.                     Exit Sub
  1150.                 End If
  1151.                 Exit Do
  1152.             Case 35
  1153.                 Trk = Label1(35).Caption
  1154.                 If Trk = "" Then
  1155.                     MousePointer = 0
  1156.                     Call MMControl1_StopClick(-1)
  1157.                     Exit Sub
  1158.                 End If
  1159.                 Exit Do
  1160.             Case 36
  1161.                 Trk = Label1(36).Caption
  1162.                 If Trk = "" Then
  1163.                     MousePointer = 0
  1164.                     Call MMControl1_StopClick(-1)
  1165.                     Exit Sub
  1166.                 End If
  1167.                 Exit Do
  1168.             Case Is > 36
  1169.                 Call MMControl1_StopClick(-1)
  1170.                 Exit Sub
  1171.             End Select
  1172.             End If
  1173.         Loop
  1174.     NewCount = NewCount + 1
  1175.     MMControl1.UpdateInterval = 1000
  1176.     ' Assure that the last track is played.
  1177.     If Trk = Val(Label2.Caption) Then
  1178.         MMControl1.From = Trk
  1179.         MMControl1.Command = "Play"
  1180.     Else
  1181.         MMControl1.From = Trk
  1182.         MMControl1.To = Trk + 1
  1183.         MMControl1.Command = "Play"
  1184.     End If
  1185.     MousePointer = 0
  1186. End Sub
  1187.